package com.open.pokergames.comm.repository.entity;

/**
 * <pre>
 *  创建:  梁玉涛 2018/12/12 on 14:46
 *  项目:
 *  描述:
 *  更新:
 * <pre>
 */
public class ResultInfo<T> {
    public static int ERROR = 10000;
    public static int SUCCESS = 200;
    public static int TOKEN_OVERDUE = 40001;

    public static String EVENT_TYPE_GLOBAL = "EVENT_TYPE_GLOBAL";

    private String eventType;

    private T data;
    private Integer code;
    private String msg;
    private String extra;
    private boolean isSuccess;

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public ResultInfo() {
    }

    public ResultInfo(Integer code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public ResultInfo(Integer code, String msg, String eventType) {
        this.code = code;
        this.msg = msg;
        this.eventType = eventType;
    }

    public String getEventType() {
        return eventType;
    }

    public String getExtra() {
        return extra;
    }

    public void setExtra(String extra) {
        this.extra = extra;
    }

    public void setEventType(String eventType) {
        this.eventType = eventType;
    }

    public boolean isSuccess() {
        return isSuccess;
    }

    public void setSuccess(boolean success) {
        isSuccess = success;
    }

    public static String getErrorMsg(String errorMsg) {
        if (errorMsg.contains("failed to connect")
                || errorMsg.contains("404")
                || errorMsg.contains("Failed to connect")) {
            return "服务器异常";
        } else {
            return errorMsg;
        }
    }
}
